import {Pipe, PipeTransform, NgModule} from "@angular/core";
import {CommonModule} from "@angular/common";

@Pipe({name: 'chunk'})
export class ChunkPipe implements PipeTransform {
  transform(value: any[], args: number[]): any {
    let chunk_number = args[0];
    let limit = args[1];
    return value.slice(chunk_number * limit, (chunk_number + 1) * limit)
  }
}

@NgModule(
  {
    // all components, pipes and directive which are using this module
    declarations: [ChunkPipe],
    imports: [CommonModule],
    exports: [ChunkPipe]
  })
export class ChunkPipeModule {

}


